<template>
    <Modal
            width="800"
            v-model="visible"
            :title="newtitle"
            :key="key"
    >
        <div style="width: 80%;padding-left: 10%;padding-right: 10%">
            <Spin size="large" fix v-if="Loading"></Spin>
            <Form :label-width="130" ref="formValidate" :model="formValidate"
                  :rules="ruleValidate" :disabled="disableSubmit">
                <Form-item label="提醒时间:" prop="time">
                    <DatePicker type="date" v-model="formValidate.time" placeholder="请选择提醒时间"
                                style="width: 200px"  :editable="false"></DatePicker>
                </Form-item>
            </Form>
        </div>
        <div slot="footer">
            <Button @click="cancel">取消</Button>
            <template v-if="!disableSubmit">
                <Button type="primary" @click="ok">确定</Button>
            </template>
        </div>
    </Modal>
</template>

<script>
    import {postAction} from '@/api/request'

    export default {
        data() {
            return {
                modal1: false,
                newtitle: "提醒时间调整",
                visible: false,
                disableSubmit: false,
                model: {},
                formValidate: {},
                ruleValidate: {
                    time: [
                        {required: true, type: 'date', message: '请选择提醒时间', trigger: 'change'}
                    ],
                },
                key: "",
                Loading: false,
            }
        },
        methods: {
            ok() {
                var that = this;
                this.$refs['formValidate'].validate((valid) => {
                    if (valid) {
                        that.submitFrom();
                    }
                })
            },
            submitFrom() {
                var that = this;
                that.Loading = true;
                this.formValidate.changeTime = this.DateFormat(this.formValidate.time, 'YYYY-MM-DD');
                postAction("/api/ac/subsistence/Ss02011Service/updateChangeTime", this.formValidate).then((res) => {
                    if (res.data.errcode != 0) {
                        this.$Message.error(res.data.errmsg);
                    } else {
                        that.$Message.success("提醒时间调整完成！");
                        this.$emit('ok');
                        this.visible = false;
                    }
                }).finally(() => {
                    that.Loading = false;
                });
            },
            cancel() {
                this.visible = false;
            },
            edit(row) {
                this.visible = true
                this.formValidate = Object.assign({}, row);
            },
        }
    }
</script>

<style scoped>

</style>
